#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int missingNumber(int* nums, int numsSize);
int missingNumber2(int* nums, int numsSize);
int missingNumber3(int* nums, int numsSize);
int missingNumber4(int* nums, int numsSize);

int main()
{
	return 0;
}

int missingNumber(int* nums, int numsSize)
{
	int xor = 0, xor_aux = 0;
	for (int i = 0; i < numsSize; i++) {
		xor ^= nums[i];
		xor_aux ^= i;
	}
	return xor_aux ^ numsSize ^ xor;
}

int missingNumber2(int* nums, int numsSize)
{
	int xor = 0;
	for (int i = 0; i < numsSize; i++)
		xor ^= nums[i] ^ i;

	return numsSize ^ xor;
}

int missingNumber3(int* nums, int numsSize)
{
	int sum = 0;
	for (int i = 0; i < numsSize; i++)
		sum += i - nums[i];
	return sum + numsSize;
}

int missingNumber4(int* nums, int numsSize)
{
	int sum = 0, sub = 0;
	for (int i = 0; i < numsSize; i++) {
		sum += i;
		sub += nums[i];
	}

	return sum + numsSize - sub;
}
